<template>
  <Card class="!mt-10px">
    <div class="w-full h-250px" ref="chartRef"></div>
  </Card>
</template>

<script lang="ts">
  import { defineComponent } from 'vue';
  export default defineComponent({
    name: 'SalesChart',
  });
</script>

<script lang="ts" setup>
  import { ref, onMounted } from 'vue';
  import { Card } from 'ant-design-vue';
  import * as echarts from 'echarts';

  const chartRef = ref();
  onMounted(() => {
    const myEcharts = echarts.init(chartRef.value);
    const option = {
      title: {
        text: '销售量趋势',
      },
      xAxis: {
        data: [
          '一月',
          '二月',
          '三月',
          '四月',
          '五月',
          '六月',
          '七月',
          '八月',
          '九月',
          '十月',
          '十一月',
          '十二月',
        ],
      },
      yAxis: {},
      series: {
        name: '销售量',
        type: 'bar',
        data: [22, 12, 35, 26, 44, 16, 22, 12, 35, 26, 44, 16],
        barWidth: 40,
      },
      grid: {
        top: '15%',
        bottom: 0,
        left: 0,
        right: 0,
        containLabel: true,
      },
      tooltip: {
        trigger: 'axis',
        axisPointer: {
          type: 'line',
          lineStyle: {
            width: 70,
            color: 'rgba(0, 0, 0, .1)',
          },
        },
      },
    };
    myEcharts.setOption(option);
  });
</script>
